/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package escom.ipn.modelo.delegate;

import escom.ipn.modelo.dto.PoliciaClass;
import escom.ipn.modelo.facade.adminPoliciaFacade;
import java.sql.*;
import java.util.List;
import java.util.ResourceBundle;

/**
 *
 * @author db2admin
 */
public class adminPoliciaDelegate {
private Connection cnn;
    private adminPoliciaFacade apf;
    
    public adminPoliciaDelegate(){
        ResourceBundle recursos = ResourceBundle.getBundle("escom.ipn.Recursos.Recursos");
        String usuario=recursos.getString("user");
        String clave=recursos.getString("pass");
        String url=recursos.getString("url");
        String driver=recursos.getString("driver");
        try{
            Class.forName(driver);
            cnn = DriverManager.
                    getConnection(url,usuario,clave);
        }catch(Exception e){
            e.printStackTrace(); 
        }
        apf=new adminPoliciaFacade(cnn);
    }
    
    public void guardarPolicia(PoliciaClass a)
            throws SQLException{
         apf.guardarPolicia(a);
    }
    
   public void updatePolicia(PoliciaClass a)
            throws SQLException{
         apf.update(a);
    }
    
    public List loadall()
            throws SQLException{
         return apf.mostrarTodos();
    }
    
    public List loadSelect(PoliciaClass a) 
            throws SQLException{
         return apf.loadSelect(a);
    }
    
    public List loadSelectSector(PoliciaClass a) 
            throws SQLException{
         return apf.loadSelectSector(a);
    }
    
    
    public void borrarPolicia(PoliciaClass a) 
            throws SQLException{
         apf.borrarPolicia(a);
    }
}
